class Person{
  //定义变量
  String? name;
  int? age;
  String? sex;


  //构造函数主，与类名同名
  Person({String? name,int? age,String? sex}){
    this.name=name;
    this.age=age;
    this.sex=sex;

    print('主构造函数');
  }
  //命名构造函数
  Person.male({String? name,int? age}){
    this.name=name;
    this.age=age;
    this.sex='男';


    print('命名构造函数');
  }
}
void main(List<String> args) {
  //调用主构造函数

  Person p1=new Person(name:'张三',age:18,sex:'男');
  print(p1.name);
  print(p1.age);
  print(p1.sex);
  

  //调用命名构造函数
  Person p2=new Person.male(name:'张三',age:18);
  print(p2.name);
  print(p2.age);
  print(p2.sex);


}